#include<iostream>
#include<pthread.h>
#include<unistd.h>
using namespace std;

pthread_mutex_t mymutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t mycond = PTHREAD_COND_INITIALIZER;
bool quit=false;

void* routine(void* argc)
{
    pthread_mutex_lock(&mymutex);
    while(!quit)
    {
        pthread_cond_wait(&mycond,&mymutex);
        string s = (char *)argc;
        cout << "我是线程";
        cout << s << endl;
        sleep(1);
    }
    pthread_mutex_unlock(&mymutex);
}

int main()
{
    pthread_t t1,t2;
    pthread_create(&t1,nullptr,routine,(void*)"A");
    pthread_create(&t2,nullptr,routine,(void*)"B");
    while(true)
    {
        pthread_cond_signal(&mycond);
    }
    pthread_join(t1,nullptr);
    pthread_join(t2,nullptr);
    return 0;
}